package _220309;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * @author ShadowLim
 * @create 2022-03-09-12:14
 */
public class _买不到的数目 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int a = scan.nextInt(), b = scan.nextInt();
        int max = a * b;  // 买不到的数目最大上界是a * b, >=a*b 的数目均可以凑出来
        scan.close();
        Set<Integer> set  = new HashSet<>();
        for (int i = 0; a * i < max; i++) {
            for (int j = 0; j * b + a * i < max; j++) {
                set.add(j * b + a * i);
            }
        }
        for (int i = max - 1; i >= 0; i--) {
            if (!set.contains(i)) {
                System.out.println(i);
                break;
            }
        }
    }

//    public static void main(String[] args) {
//        Scanner scan = new Scanner(System.in);
//        //在此输入您的代码...
//        int a = scan.nextInt(), b = scan.nextInt();
//        System.out.println(a * b - (a + b));
//    }
}
